<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>02_v-bind动态绑定style(对象语法)</title>

    <style>
      .title {
        font-size: 50px;
        color: cornsilk;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <!-- <h2 :style="{key(属性名), value(属性值)}">{{message}}</h2> -->
      <!-- '50px'必须加单引号，否则当成变量解析 -->
      <h2 :style="{fontSize:'50px'}">{{message}}</h2>
      <!--  finalSize没有加单引号，当成变量去解析-->
      <h2 :style="{fontSize:finalSize,color:finalColor}">{{message}}</h2>
      <!-- 减少长度 -->
      <h2 :style="getStyle()">{{message}}</h2>
    </div>
    <script src="../vue.js"></script>

    <script>
      const app = new Vue({
        el: "#app",
        data: {
          message: "hello",
          finalSize: "100px",
          finalColor: "blue",
        },
        methods: {
          getStyle: function () {
            return { fontSize: this.finalSize, color: this.finalColor };
          },
        },
      });
    </script>
  </body>
</html>
